package mhcs.client;

/**
 * Module is a simple data structure storing the information
 * for a single mhcs module.
 * There are no public setters, so editing must be done through replacement.
 * @author Galen Maxim
 * v 0.3
 * commentary added and CheckStyle run
 */
public class Module implements Comparable<Module> {

    /**
     * default constructor Module() is set to private
     * so empty modules cannot be instantiated.
     */
    private Module() {
        super();
    }

    /**
     * @param srl   serial number
     * @param mod  module type
     * @param stat  module status
     * @param rtns  rotations needed
     * @param ex    X coordinate
     * @param why   Y coordinate
     */
    public Module(final int srl, final String mod, final String stat,
                   final int rtns, final int ex, final int why) {
        serial = srl;
        type = mod;
        status = stat;
        rotations = rtns;
        x = ex;
        y = why;
    }

    /**
     * @return String serial
     */
    public final int getSerial() {
        return serial;
    }

    /**
     * @return String type
     */
    public final String getType() {
        return type;
    }

    /**
     * @return String status
     */
    public final String getStatus() {
        return status;
    }

    /**
     * @return int rotations
     */
    public final int getRotations() {
        return rotations;
    }

    /**
     * @return int x
     */
    public final int getX() {
        return x;
    }


    /**
     * @return int y
     */
    public final int getY() {
        return y;
    }


    /**
     * Module serial number.
     */
    private int serial;

    /**
     * The status of damage to the module.
     */
    private String status;

    /**
     * The module's type.
     */
    private String type;

    /**
     * The number of rotations needed to set the module upright.
     */
    private int rotations;

    /**
     * The module's x-coordinate.
     */
    private int x;

    /**
     * The module's y-coordinate.
     */
    private int y;


    /**
     * Overriding compareTo so modules can automatically
     * be sorted by serial number.
     * @param o the Module being compared to.
     * @return returns a positive number if the calling module has
     * a lexicographically higher serial number, 0 if they're the same,
     * and a negative number if it is lower.
     */
    @Override
    public final int compareTo(final Module o) {
        return serial - o.getSerial();
    }

}
